<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/12
 * Time: 10:24
 * Project name: PHPTEST
 * File name: 1.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

/**
 * 判断变量的类型用is_type 函数
 */
$an_int = 1;
if ( is_int( $an_int ) ) {
	$an_int += 4;
}
echo $an_int . PHP_EOL;
$a_bool = '^_^';
if ( is_string( $a_bool ) ) {
	echo "String: $a_bool" . PHP_EOL;
}
//判断变量
//is_array( mixed $var )
//is_bool( mixed $var )
//is_float( mixed $var )
//is_integer( mixed $var )
//is_null( mixed $var )
//is_numeric( mixed $var ) //检测变量是否为数字或数字字符串
//is_object( mixed $var )
//is_resource( mixed $var )
//is_scalar( mixed $var ) //检测变量是否是一个标量  integer、float、string 或 boolean
//is_string( mixed $var )


$str = '0.00';
$ret = ! empty( $str ) ? $str : '5.00';
echo $ret . PHP_EOL;
//当字符串 与 数字比较时，会被转换为数字之后进行比较
echo ( "123" == 123 ) . PHP_EOL;

//97
echo ord( "a" ) . PHP_EOL;
echo chr( 97 ) . PHP_EOL;


$arr = [
	1 => 'a',
	2 => 'b',
	3 => 'c',
	4 => 'd',
];

var_dump( $arr );
unset( $arr[2] );
var_dump( $arr );
var_dump( array_values( $arr ) );

$binary = (binary) ( "binary string" );
echo $binary . PHP_EOL;

$array = [
	[ 1, 2, 3 ],
	[ 3, 4, 5 ],
];

foreach ( $array as list( $a, $b, $c ) ) {
	// $a contains the first element of the nested array,
	// and $b contains the second element.
	echo "A: $a; B: $b; C: $c\n";
}